import 'package:flutter/material.dart';
import '../../../utils/base.dart';

class StatsItem extends StatelessWidget {
  final String title;

  final int num;

  final String unit;

  final bool isActive;

  final VoidCallback onPressed;

  const StatsItem({Key key, this.onPressed, this.title, this.num, this.unit, this.isActive})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    BoxDecoration _background() {
      BoxDecoration _defaultBoxDecoration = BoxDecoration(
        color: HexColor("ffffff"),
        borderRadius: new BorderRadius.circular(Design.px(17)),
      );

      BoxDecoration _activeBoxDecoration = _defaultBoxDecoration.copyWith(
        color: HexColor("ffeabd"),
      );

      return isActive ? _activeBoxDecoration : _defaultBoxDecoration;
    }

    TextStyle _dataTextStyle() {
      return TextStyle(
        fontSize: Design.px(35),
        decoration: TextDecoration.none,
        color: isActive ? HexColor("ff6666") : HexColor("333333"),
        height: 1.5,
      );
    }

    TextStyle _titleTextStyle() {
      return TextStyle(
        fontSize: Design.px(27),
        decoration: TextDecoration.none,
        color: isActive ? HexColor("ff6666") : HexColor("666666"),
        height: 1.5,
      );
    }

    return Container(
      decoration: _background(),
      child: FlatButton(
        onPressed: onPressed,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              '$num$unit',
              style: _dataTextStyle(),
            ),
            Text(
              '$title',
              style: _titleTextStyle(),
            ),
          ],
        ),
      ),
    );
  }
}
